import { OrderFees } from './orderFee';
let _OrderFees = OrderFees;
/**
 * 拷贝下面两行到 mock/index.js中,即可支持客户端虚拟数据、免服务端连接
 * import OrderFeeMock from './mk/mng/computed/orderFeeMock';
 * OrderFeeMock.bootstrap(mock);
 */
export default {
  /**
   * mock bootstrap
   */
  bootstrap(mock) {    
  
    //获取列表 模糊查询、根据关键字查询
    mock.onGet('/mk/mng/computed/orderFee/listKey').reply(config => {
      let params = config.params;
      let mockOrderFees = _OrderFees.filter(orderFee => {
      	if(params.orderId||params.orderId==''){ if( orderFee.orderId.indexOf(params.orderId)>=0) return true;}
      	if(params.orderTotalFee||params.orderTotalFee==''){ if( orderFee.orderTotalFee.indexOf(params.orderTotalFee)>=0) return true;}
      	if(params.orderTotalAmount||params.orderTotalAmount==''){ if( orderFee.orderTotalAmount.indexOf(params.orderTotalAmount)>=0) return true;}
      	if(params.orderActPayAmount||params.orderActPayAmount==''){ if( orderFee.orderActPayAmount.indexOf(params.orderActPayAmount)>=0) return true;}
      	if(params.orderReduceAmount||params.orderReduceAmount==''){ if( orderFee.orderReduceAmount.indexOf(params.orderReduceAmount)>=0) return true;}
      	if(params.custId||params.custId==''){ if( orderFee.custId.indexOf(params.custId)>=0) return true;}
      	if(params.flowId||params.flowId==''){ if( orderFee.flowId.indexOf(params.flowId)>=0) return true;}
      	if(params.flowStatus||params.flowStatus==''){ if( orderFee.flowStatus.indexOf(params.flowStatus)>=0) return true;}
      	if(params.acctDate||params.acctDate==''){ if( orderFee.acctDate.indexOf(params.acctDate)>=0) return true;}
      	if(params.accountDate||params.accountDate==''){ if( orderFee.accountDate.indexOf(params.accountDate)>=0) return true;}
      	if(params.actStaffFee||params.actStaffFee==''){ if( orderFee.actStaffFee.indexOf(params.actStaffFee)>=0) return true;}
      	if(params.startComputeDate||params.startComputeDate==''){ if( orderFee.startComputeDate.indexOf(params.startComputeDate)>=0) return true;}
      	if(params.orderPayDate||params.orderPayDate==''){ if( orderFee.orderPayDate.indexOf(params.orderPayDate)>=0) return true;}
      	if(params.remark||params.remark==''){ if( orderFee.remark.indexOf(params.remark)>=0) return true;}
      	if(params.orderDistrictId||params.orderDistrictId==''){ if( orderFee.orderDistrictId.indexOf(params.orderDistrictId)>=0) return true;}
      	if(params.custDistrictId||params.custDistrictId==''){ if( orderFee.custDistrictId.indexOf(params.custDistrictId)>=0) return true;}
      	if(params.mkStaff||params.mkStaff==''){ if( orderFee.mkStaff.indexOf(params.mkStaff)>=0) return true;}
      	if(params.mkStaffName||params.mkStaffName==''){ if( orderFee.mkStaffName.indexOf(params.mkStaffName)>=0) return true;}
      	if(params.custName||params.custName==''){ if( orderFee.custName.indexOf(params.custName)>=0) return true;}
      	if(params.custDistrictName||params.custDistrictName==''){ if( orderFee.custDistrictName.indexOf(params.custDistrictName)>=0) return true;}
      	if(params.orderDistrictName||params.orderDistrictName==''){ if( orderFee.orderDistrictName.indexOf(params.orderDistrictName)>=0) return true;}
        return false;
      });
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          resolve([200, {
            data: mockOrderFees
          }]);
        }, 1000);
      });
    });
    
    

    //获取列表（分页/不分页）
    mock.onGet('/mk/mng/computed/orderFee/list').reply(config => {
      let params = config.params;
      let mockOrderFees = _OrderFees.filter(orderFee => {
      	var isTrue=false;
      	if(params.orderId||params.orderId==''){if(orderFee.orderId.indexOf(params.orderId)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.orderTotalFee||params.orderTotalFee==''){if(orderFee.orderTotalFee.indexOf(params.orderTotalFee)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.orderTotalAmount||params.orderTotalAmount==''){if(orderFee.orderTotalAmount.indexOf(params.orderTotalAmount)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.orderActPayAmount||params.orderActPayAmount==''){if(orderFee.orderActPayAmount.indexOf(params.orderActPayAmount)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.orderReduceAmount||params.orderReduceAmount==''){if(orderFee.orderReduceAmount.indexOf(params.orderReduceAmount)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.custId||params.custId==''){if(orderFee.custId.indexOf(params.custId)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.flowId||params.flowId==''){if(orderFee.flowId.indexOf(params.flowId)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.flowStatus||params.flowStatus==''){if(orderFee.flowStatus.indexOf(params.flowStatus)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.acctDate||params.acctDate==''){if(orderFee.acctDate.indexOf(params.acctDate)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.accountDate||params.accountDate==''){if(orderFee.accountDate.indexOf(params.accountDate)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.actStaffFee||params.actStaffFee==''){if(orderFee.actStaffFee.indexOf(params.actStaffFee)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.startComputeDate||params.startComputeDate==''){if(orderFee.startComputeDate.indexOf(params.startComputeDate)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.orderPayDate||params.orderPayDate==''){if(orderFee.orderPayDate.indexOf(params.orderPayDate)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.remark||params.remark==''){if(orderFee.remark.indexOf(params.remark)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.orderDistrictId||params.orderDistrictId==''){if(orderFee.orderDistrictId.indexOf(params.orderDistrictId)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.custDistrictId||params.custDistrictId==''){if(orderFee.custDistrictId.indexOf(params.custDistrictId)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.mkStaff||params.mkStaff==''){if(orderFee.mkStaff.indexOf(params.mkStaff)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.mkStaffName||params.mkStaffName==''){if(orderFee.mkStaffName.indexOf(params.mkStaffName)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.custName||params.custName==''){if(orderFee.custName.indexOf(params.custName)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.custDistrictName||params.custDistrictName==''){if(orderFee.custDistrictName.indexOf(params.custDistrictName)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.orderDistrictName||params.orderDistrictName==''){if(orderFee.orderDistrictName.indexOf(params.orderDistrictName)>=0){isTrue=true;}else{isTrue=false;}}
      	return isTrue;
	  });
      if(!config.params.currentPage){ 
	      return new Promise((resolve, reject) => {
	        setTimeout(() => {
	          resolve([200, {
	            data: mockOrderFees
	          }]);
	        }, 1000);
	      });
      }
    
      let {pageSize,currentPage, total} = config.params;
      total = mockOrderFees.length;
      mockOrderFees = mockOrderFees.filter((orderFee, index) => index < pageSize * currentPage && index >= pageSize * (currentPage - 1));
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          resolve([200, {
            pageInfo: {
            	total:total
            },
            data: mockOrderFees,
            tips:{
            	isOk:true,
            	msg:'查询成功'
            }
          }]);
        }, 1000);
      });
    });

    //删除
    mock.onPost('/mk/mng/computed/orderFee/del').reply(config => {
      var params = JSON.parse( config.data );
      let {  orderId  } = params;
      _OrderFees = _OrderFees.filter(orderFee => orderFee.orderId !== orderId);
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          resolve([200, {
            tips:{
            	isOk:true,
            	msg:'删除成功'
            }
          }]);
        }, 500);
      });
    });

    //批量删除
    mock.onPost('/mk/mng/computed/orderFee/batchDel').reply(config => {
      var params = JSON.parse( config.data );
      _OrderFees = _OrderFees.filter(orderFee => !params.includes(orderFee.orderId));
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          resolve([200, {
           tips:{
            	isOk:true,
            	msg:'删除成功'
            }
          }]);
        }, 500);
      });
    });

    //编辑
    mock.onPost('/mk/mng/computed/orderFee/edit').reply(config => {
      var params = JSON.parse( config.data );
      let { orderId,orderTotalFee,orderTotalAmount,orderActPayAmount,orderReduceAmount,custId,flowId,flowStatus,acctDate,accountDate,actStaffFee,startComputeDate,orderPayDate,remark,orderDistrictId,custDistrictId,mkStaff,mkStaffName,custName,custDistrictName,orderDistrictName } = params;
      _OrderFees.some(orderFee => {
        if (orderFee.orderId === orderId) {
			orderFee.orderId = orderId;
			orderFee.orderTotalFee = orderTotalFee;
			orderFee.orderTotalAmount = orderTotalAmount;
			orderFee.orderActPayAmount = orderActPayAmount;
			orderFee.orderReduceAmount = orderReduceAmount;
			orderFee.custId = custId;
			orderFee.flowId = flowId;
			orderFee.flowStatus = flowStatus;
			orderFee.acctDate = acctDate;
			orderFee.accountDate = accountDate;
			orderFee.actStaffFee = actStaffFee;
			orderFee.startComputeDate = startComputeDate;
			orderFee.orderPayDate = orderPayDate;
			orderFee.remark = remark;
			orderFee.orderDistrictId = orderDistrictId;
			orderFee.custDistrictId = custDistrictId;
			orderFee.mkStaff = mkStaff;
			orderFee.mkStaffName = mkStaffName;
			orderFee.custName = custName;
			orderFee.custDistrictName = custDistrictName;
			orderFee.orderDistrictName = orderDistrictName
          return true;
        }
      });
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          resolve([200, {
            tips:{
            	isOk:true,
            	msg:'编辑成功'
            }
          }]);
        }, 500);
      });
    });

    //新增
    mock.onPost('/mk/mng/computed/orderFee/add').reply(config => {
      var params = JSON.parse( config.data );
      let { orderId,orderTotalFee,orderTotalAmount,orderActPayAmount,orderReduceAmount,custId,flowId,flowStatus,acctDate,accountDate,actStaffFee,startComputeDate,orderPayDate,remark,orderDistrictId,custDistrictId,mkStaff,mkStaffName,custName,custDistrictName,orderDistrictName } = params;
      _OrderFees.push({
		orderId:orderId,
		orderTotalFee:orderTotalFee,
		orderTotalAmount:orderTotalAmount,
		orderActPayAmount:orderActPayAmount,
		orderReduceAmount:orderReduceAmount,
		custId:custId,
		flowId:flowId,
		flowStatus:flowStatus,
		acctDate:acctDate,
		accountDate:accountDate,
		actStaffFee:actStaffFee,
		startComputeDate:startComputeDate,
		orderPayDate:orderPayDate,
		remark:remark,
		orderDistrictId:orderDistrictId,
		custDistrictId:custDistrictId,
		mkStaff:mkStaff,
		mkStaffName:mkStaffName,
		custName:custName,
		custDistrictName:custDistrictName,
		orderDistrictName:orderDistrictName
      });
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          resolve([200, {
            tips:{
            	isOk:true,
            	msg:'新增成功'
            }
          }]);
        }, 500);
      });
    });

  }
};